package com.gdut.simple.data.entity;

import android.os.Parcel;
import android.os.Parcelable;

import java.util.ArrayList;
import java.util.List;

import cn.bmob.v3.BmobObject;
import cn.bmob.v3.datatype.BmobFile;

public class Post extends BmobObject implements Parcelable {

    private User author;
    private String content;
    private List<BmobFile> images;

    public Post() {
    }

    protected Post(Parcel in) {
        this.author = (User) in.readSerializable();
        this.content = in.readString();
        this.images = new ArrayList<>();
        in.readList(this.images, BmobFile.class.getClassLoader());
    }

    public User getAuthor() {
        return author;
    }

    public void setAuthor(User author) {
        this.author = author;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public List<BmobFile> getImages() {
        return images;
    }

    public void setImages(List<BmobFile> images) {
        this.images = images;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeSerializable(this.author);
        dest.writeString(this.content);
        dest.writeList(this.images);
    }

    public static final Creator<Post> CREATOR = new Creator<Post>() {
        @Override
        public Post createFromParcel(Parcel source) {
            return new Post(source);
        }

        @Override
        public Post[] newArray(int size) {
            return new Post[size];
        }
    };

    @Override
    public String toString() {
        return "Post{" +
                "author=" + author +
                ", content='" + content + '\'' +
                ", images=" + images +
                '}';
    }
}
